package com.bdqn.service.impl;

import com.bdqn.mapper.SysUserMapper;
import com.bdqn.pojo.SysUser;
import com.bdqn.service.SysUserService;
import com.bdqn.util.Page;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SysUserServiceImpl implements SysUserService {
    @Resource
    private SysUserMapper sysUserDao;

    @Override
    public SysUser login(String account, String password) {
        if (account == null || password == null){
            return null;
        }
        return sysUserDao.login(account , password);
    }

    @Override
    public Long count(String queryRealName, Long queryRoleId) {
        return sysUserDao.count(queryRealName , queryRoleId);
    }

    @Override
    public List<SysUser> page(String queryRealName, Long queryRoleId , Page page) {
        Long pageSize = page.getPageSize();
        Long pageIndex = (page.getCurrentPageNo()-1)*pageSize;

        return sysUserDao.page(queryRealName , queryRoleId , pageSize , pageIndex);
    }

    @Override
    public int add(SysUser user) {
        return sysUserDao.add(user);
    }

    @Override
    public int del(int id) {
        return sysUserDao.del(id);
    }
}
